# from flask import Flask
#
# app = Flask(__name__)
#
#
# if __name__ == '__main__':
#     app.run()


from flask import Flask
from flask import request

app = Flask(__name__)


@app.before_first_request
def handle_before_first_request():
    print("-----before_first_request-----")


@app.before_request
def handle_before_request():
    print("-----before_request-----")


@app.after_request
def handle_after_request(response):
    print("-----after_request-----")
    return response


@app.teardown_request
def handle_teardown_request(response):
    print("#####teardown_request#####")
    path = request.path
    if path == "/index":
        print("这是首页路径名:",path)
    elif path == "/hello":
        print("This is HELLO\'pathname:",path)
    return response


@app.route("/index")
def index():
    return "Index 首页页面!"


@app.route("/hello")
def hello():
    return "Hello World"


if __name__ == '__main__':
    app.run(port=5003, debug=True)
